var webpack = require('webpack');

var baseConfigInit = require('./webpack.base.config');

const CleanWebpackPlugin = require('clean-webpack-plugin') ;

var baseConfig = baseConfigInit("PROD");

var prodConfig = {
    plugins:[
        new webpack.optimize.OccurrenceOrderPlugin(true),
        //js压缩参数
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false,
                drop_console: true
            },
            beautify:false,
            comments:false
        }),
        new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: '"production"'
            }
        }),
        new webpack.LoaderOptionsPlugin({
            minimize: true
        })
    ]
};

// //打包清除文件
baseConfig.plugins.push(new CleanWebpackPlugin(
    'dist',　 //匹配删除的文件,
    {
        root: __dirname, //根目录
        verbose:  true, //开启在控制台输出信息
        dry:      false //启用删除文件
    }
));
baseConfig.output.publicPath = "";

baseConfig.plugins = prodConfig.plugins.concat( baseConfig.plugins );

module.exports = baseConfig;